import http from "@/utils/http";

export const createScript = (data) => {
    return http.post(`script/`, data)
}

export const getScripts = () => {
    return http.get("script/list/")
}

export const getScriptDetail = (name) => {
    return http.get("script/", { params: { name } })
}

export const updateScript = (name, data) => {
    return http.put("script/", data, { params: { name } })
}

/**
 * 删除指定名称的客户端
 * @param {String} name - 将要删除的客户端名称
 * @return {Promise<Object>}
 */
export const removeScript = (name) => {
    return http.delete("script/", { params: { name } })
}

export const testScript = (client, device, script) => {
    return http.post("script/test/", {
        client, device, script
    })
}
